<script>
	import config from './config'
	import { getToken } from '@/utils/auth'
	export default {
		onLaunch: function() {
			// #ifdef APP-PLUS
			plus.navigator.closeSplashscreen();

			// 判断是否是平板
			uni.getSystemInfo({
				success: (res) => {
					if (res.windowWidth > 500) {
						plus.screen.lockOrientation('landscape-primary'); //平板横屏锁定
						console.log("平板横屏锁定")
					} else {
						plus.screen.lockOrientation('portrait-primary'); //手机竖屏锁定
						console.log("手机竖屏锁定")
					}
				}
			});
			// #endif
			// console.log('App Launch')
			this.initApp()
		},
		onShow: function() {},
		onHide: function() {},

		methods: {

			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()
				this.checkLogin()
				this.loadData()

			},
			initConfig() {
				this.globalData.config = config
			},
			checkLogin() {
				if (!getToken()) {
					this.$tab.reLaunch('/pages/login/login')
				}
			},
			async loadData() {
				await this.$store.dispatch('GetAllDepartMent')
				await this.$store.dispatch('GetAllPost')
				console.log('stroe:', this.$store)

			},

		},

	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/css/index.scss';
	@import '@/common/uni.css';

body {
	background-color: #f5f6f7;
}

	.tabbar {
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		height: 110rpx;
		background-color: #FFFFff;

		.tabbar__item {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			flex: 1;
		}

		.tabbar__svg {
			display: flex;
			width: 20px;
			height: 20px;

			svg {
				width: 100%;
				height: 100%;

				.icon {
					fill: none;
					stroke: #AFB8CC;
					stroke-dashoffset: 98;
					stroke-width: 2px;
					stroke-linecap: round;
					stroke-linejoin: round;
				}
			}
		}

		.tabbar__name {
			height: auto;
			padding-top: 2px;
			font-size: 9px;
			transition: color .3s;
			color: #AFB8CC;

		}

		.on {
			.tabbar__name {
				color: #698AFF;
			}

			svg {
				//如果不需要跳动效果删除下方动画
				animation: heartbeat 1s;

				.icon {
					fill: none;
					stroke: #AFB8CC;
					stroke-dashoffset: 98;
					stroke-width: 2px;
					stroke-linecap: round;
					stroke-linejoin: round;

				}

				.icon:nth-child(2) {
					opacity: 0;
					stroke: #698AFF;
					-webkit-animation-delay: 0.2s !important;
					animation-delay: 0.2s !important;
					-webkit-animation: stroke-animation .5s linear;
					animation: stroke-animation .5s linear;
				}

				.icon:nth-child(3) {
					opacity: 0;
					stroke: #FF5100;
					-webkit-animation-delay: 0.3s !important;
					animation-delay: 0.3s !important;
					-webkit-animation: stroke-animation .5s linear;
					animation: stroke-animation .5s linear;
				}

				.icon:nth-child(4) {
					opacity: 0;
					stroke: #FFB400;
					-webkit-animation-delay: 0.4s !important;
					animation-delay: 0.4s !important;
					-webkit-animation: stroke-animation .5s linear;
					animation: stroke-animation .5s linear;
				}

				.icon:nth-child(5) {
					opacity: 0;
					stroke: #698AFF;
					-webkit-animation-delay: 0.5s !important;
					animation-delay: 0.5s !important;
					-webkit-animation: stroke-animation-last .5s linear forwards;
					animation: stroke-animation-last .5s linear forwards;
				}
			}
		}
	}

	/**
		 * 心跳动画图标的跳动效果
		 */
	@keyframes heartbeat {
		0% {
			transform: scale(1);
		}

		20% {
			transform: scale(0.8);
		}

		40% {
			transform: scale(1);
		}

		60% {
			transform: scale(0.9);
		}

		80%,
		100% {
			transform: scale(1);
		}
	}

	/**
		 * 图标流光效果
		 */
	@-webkit-keyframes stroke-animation-first {
		0% {
			opacity: 1;
			stroke-dashoffset: 98;
			stroke-dasharray: 98 0;
		}

		100% {
			opacity: 0;
			stroke-dashoffset: 0;
			stroke-dasharray: 0 98;
		}
	}

	@keyframes stroke-animation-first {
		0% {
			opacity: 1;
			stroke-dashoffset: 98;
			stroke-dasharray: 98 0;
		}

		100% {
			opacity: 0;
			stroke-dashoffset: 0;
			stroke-dasharray: 0 98;
		}
	}

	@-webkit-keyframes stroke-animation {
		0% {
			opacity: 1;
			stroke-dashoffset: 98;
			stroke-dasharray: 0 98 0 0;
		}

		15% {
			stroke-dasharray: 0 98 18 0;
		}

		100% {
			opacity: 1;
			stroke-dashoffset: 0;
			stroke-dasharray: 0 98 18 0;
		}
	}

	@keyframes stroke-animation {
		0% {
			opacity: 1;
			stroke-dashoffset: 98;
			stroke-dasharray: 0 98 0 0;
		}

		15% {
			stroke-dasharray: 0 98 18 0;
		}

		100% {
			opacity: 1;
			stroke-dashoffset: 0;
			stroke-dasharray: 0 98 18 0;
		}
	}

	@-webkit-keyframes stroke-animation-last {
		0% {
			opacity: 1;
			stroke-dashoffset: 98;
			stroke-dasharray: 98 98 18 0;
		}

		15% {
			stroke-dasharray: 116 98 18 0;
		}

		100% {
			opacity: 1;
			stroke-dashoffset: 0;
			stroke-dasharray: 116 98 18 0;
		}
	}

	@keyframes stroke-animation-last {
		0% {
			opacity: 1;
			stroke-dashoffset: 98;
			stroke-dasharray: 98 98 18 0;
		}

		15% {
			stroke-dasharray: 116 98 18 0;
		}

		100% {
			opacity: 1;
			stroke-dashoffset: 0;
			stroke-dasharray: 116 98 18 0;
		}
	}

	@-webkit-keyframes click-animation {
		50% {
			-webkit-transform: scale(4);
			transform: scale(4);
			opacity: .1;
		}
	}

	@keyframes click-animation {
		50% {
			-webkit-transform: scale(4);
			transform: scale(4);
			opacity: .1;
		}
	}
</style>